# In case you forget to add 'sudo', say damn

# the location of the fish history file is based on the version
# ~/.local/share/fish/fish_history for 2.3.0 and later
# ~/.config/fish/fish_history before that


function damn
set location "~/.local/share/fish/fish_history"
set currentV (echo $FISH_VERSION | string replace -a "." "")

if [ $currentV -lt "230" ]
    set location "~/.config/fish/fish_history"
end
set location (string replace "~" "$HOME" "$location")
set lastCmd "sudo "(tail -n20 $location | tac | grep -m2 "^-" |tail -n1 | sed "s_- cmd: __g" | sed 's_\\\\\\\\_\\\\_g')
echo -e "\033[1;32m damn: \033[1;31m"$lastCmd"\033[0m"
eval $lastCmd

end
